Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

catch-links

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catch-links

intercept local link clicks on a page

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66
increased by60.98%
Maintainers
1
Weekly downloads
 
Created
Source

intercept local link clicks on a page

This is useful for doing client-side pushState UIs.

example

Given some html:

<html>
  <body>
    <div>
      <a href="/a">aaa</a>
    </div>

    <div>
      <a href="/b">bbb</a>
    </div>

    <div>
      <a href="cc">cc</a>
    </div>
    
    <div>
      <a href="http://npmjs.org">npmjs</a>
    </div>
    
    <script src="bundle.js"></script>
  </body>
</html>

We'll intercept the relative links <host>/a and <host>/b, printing them. The external link to npmjs.org will go through as usual.

var catchLinks = require('catch-links');

catchLinks(window, function (href) {
    console.log(href);
});

methods

var catchLinks = require('catch-links')

catchLinks(element, cb)

Fire cb(href) whenever an anchor tag descendant of element with an in-server url is clicked.

href will always be a relative path rooted at the root path.

install

With npm do:

npm install catch-links

Use browserify to bundle this library into your project.

license

MIT

Keywords

FAQs

Package last updated on 24 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc